const state = {
	count: 0,
	firstName: '请叫我',
	lastName: '足下',
	money: 1,
	fullName: "",
	fullPath: "是不是用命名空间获取state"
}

// getters
const getters = {
	fullName(state) {
		return `${state.firstName}  ${state.lastName}`
	}


}

// actions
const actions = {
	updateCountAsync(store, data) {
		// console.log('asdasd')
		console.log(data)
		setInterval(() => {
			store.commit('updateCount', {
				num: data.num
			})
		}, data.time)
	},

	addMoney(store, data) {
		store.commit('addMoney', data)
	}


}

// mutations
const mutations = {

	// 只收到一个参数
	// updateCount (state, num) {
	//   state.count = num
	// }
	// 这种写法就是收多个参数的情况

	updateCount(state, {
		num,
		num2
	}) {
		console.log('num=======：' + num)
		console.log('num2=======：' + num2)
		state.count += num
	},
	addMoney(state, data) {
		state.money += data
	}
}



export default {
	namespaced: true,
	state,
	getters,
	actions,
	mutations
}
